﻿#ifndef AVCONVERT_H
#define AVCONVERT_H

extern "C"
{
#include "libavformat/avformat.h"
};

class AVAudioConvert
{
private:
    struct SwrContext *m_aud_convert_ctx = NULL;
    uint8_t **dstBuffer = NULL;
    int m_outSampleRate;
    int m_outChannels;
    int m_outFormat;
public:
    AVAudioConvert(int inSample,int inChannel,int inFormat,int outSample,int outChannel,int outFormat);
    ~AVAudioConvert();
    /* outBuf由外部提供，数据大小和采样点数量也由外部提供  */
    int audio_rescale_private(int srcSampleRate,int srcChannels,int srcFormat,int srcNbSamples,uint8_t **srcData, int dstSampleRate, int dstChannels, enum AVSampleFormat dstSampleFormat,  uint8_t *outBuf, int *outBufSize, int *outNbSamples,int *linesize);
    int audio_rescale(AVFrame *srcFrame,  uint8_t *outBuf, int *outBufSize, int *outNbSamples);
};

#endif // AVCONVERT_H
